package com.prs.crm.action.oa.schedule;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.assets.AssetsRegister;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.domain.oa.schedule.CommonSchedule;
import com.prs.crm.domain.oa.schedule.CycleSchedule;
import com.prs.crm.domain.oa.schedule.IntervalSchedule;
import com.prs.crm.domain.oa.schedule.MyThings;
import com.prs.crm.domain.warning.TaskRemind;
import com.prs.crm.report.ExportConfig;
import com.prs.crm.report.ReportCell;
import com.prs.crm.report.ReportTable;
import com.prs.crm.service.hr.PersonService;
import com.prs.crm.service.oa.schedule.CommonScheduleService;
import com.prs.crm.service.oa.schedule.CycleScheduleService;
import com.prs.crm.service.oa.schedule.IntervalScheduleService;
import com.prs.crm.service.oa.schedule.MyThingsService;
import com.prs.crm.service.warning.TaskRemindService;
import com.prs.crm.tools.Datetools;
/**
 * @author YangHao
 * @E-Mail:450098606@qq.com
 * @qq:450098606
 * @version 创建时间：2012-4-16 14:07:59 新事务
 */
public class MyThingsAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private MyThings myThings;
	private MyThingsService myThingsService;
	private PaginationSupport pagination;
	private TaskRemindService taskRemindService;
	private PersonService personService;
	private String personName;
	public String getPersonName() {
		return personName;
	}
	public void setPersonName(String personName) {
		this.personName = personName;
	}
	public PersonService getPersonService() {
		return personService;
	}
	public void setPersonService(PersonService personService) {
		this.personService = personService;
	}
	public TaskRemindService getTaskRemindService() {
		return taskRemindService;
	}
	public void setTaskRemindService(TaskRemindService taskRemindService) {
		this.taskRemindService = taskRemindService;
	}

	private Integer[] ids;
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	public MyThings getMyThings() {
		return myThings;
	}
	public void setMyThings(MyThings myThings) {
		this.myThings = myThings;
	}
	public MyThingsService getMyThingsService() {
		return myThingsService;
	}
	public void setMyThingsService(MyThingsService myThingsService) {
		this.myThingsService = myThingsService;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	@Action("listMyThings")
	public String listMyThings(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(MyThings.class).add(Restrictions.eq("mt_type", "普通日程"));
		criteria.add(Restrictions.eq("receivePersonName", AppContext.getAccountContext().currentUser().getResume().getName()));
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getMyThingsService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action("listAllotMyThings")
	public String listAllotMyThings(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(MyThings.class).add(Restrictions.eq("mt_type", "普通日程"));
		criteria.add(Restrictions.not(Restrictions.eq("receivePersonName", AppContext.getAccountContext().currentUser().getResume().getName())));
		criteria.add(Restrictions.eq("recorder.id", AppContext.getAccountContext().currentUser().getId()));
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getMyThingsService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action("listAllMyThings")
	public String listAllMyThings(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(MyThings.class).add(Restrictions.eq("mt_type", "普通日程"));
		if (myThings!=null) {
			criteria.add(Restrictions.eq("receivePersonNameId", myThings.getReceivePersonNameId()));
			Person per=this.getPersonService().getPersonById(Integer.parseInt(myThings.getReceivePersonNameId()));
			personName=per.getResume().getName();
		}
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getMyThingsService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action("listCycleMyThings")
	public String listCycleMyThings() throws ParseException{
		List<MyThings> mh=this.getMyThingsService().getMyThings();
		for (MyThings mt : mh) {
			if ("按天".equals(mt.getJiange())) {
				Date da=new Date();
				String starttime=mt.getStartTime();
				String num=mt.getDateTime();
				Integer nums=Integer.parseInt(num);
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(starttime);
				String time=sf.format(new Date(dat.getTime()+(nums+1)*24*60*60*1000));
				Date dat1=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(time);
				Date dat2=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(sf.format(da));
				if (dat1.equals(dat2) || dat2.after(dat1)) {
					MyThings mth=this.getMyThingsService().getTime(time);
					if (mth==null) {
						mth=new MyThings();
						mth.setMt_type(mt.getMt_type());
						mth.setJiange(mt.getJiange());
						mth.setDateTime(mt.getDateTime());
						mth.setCycleStratTime(mt.getCycleStratTime());
						mth.setShichang(mt.getShichang());
						mth.setMt_thingsContext(mt.getMt_thingsContext());
						mth.setMt_importance(mt.getMt_importance());
						mth.setSendInfo(mt.getSendInfo());
						mth.setSendShouji(mt.getSendShouji());
						mth.setSendEmail(mt.getSendEmail());
						mth.setStartWarn(mt.getStartWarn());
						mth.setOutWarn(mt.getOutWarn());
						mth.setOverWarn(mt.getOverWarn());
						mth.setStartTime(time);
						mth.setMt_state("未完成");
						this.getMyThingsService().save(mth);
					}
				}
			}else if("按月".equals(mt.getJiange())){
				Date da=new Date();
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(mt.getStartTime());
				Calendar ca1=Calendar.getInstance();
				ca1.setTime(dat);
				ca1.add(Calendar.MONTH, 1);
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
				Date dat1=ca1.getTime();
				Date dat2=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(sf.format(da));
				if (dat1.equals(dat2) || dat2.after(dat1)) {
					MyThings mth=this.getMyThingsService().getTime(sf.format(dat1));
					if (mth==null) {
						mth=new MyThings();
						mth.setMt_type(mt.getMt_type());
						mth.setJiange(mt.getJiange());
						mth.setMonthTime(mt.getMonthTime());
						mth.setCycleStratTime(mt.getCycleStratTime());
						mth.setShichang(mt.getShichang());
						mth.setMt_thingsContext(mt.getMt_thingsContext());
						mth.setMt_importance(mt.getMt_importance());
						mth.setSendInfo(mt.getSendInfo());
						mth.setSendShouji(mt.getSendShouji());
						mth.setSendEmail(mt.getSendEmail());
						mth.setStartWarn(mt.getStartWarn());
						mth.setOutWarn(mt.getOutWarn());
						mth.setOverWarn(mt.getOverWarn());
						mth.setStartTime(sf.format(dat1));
						mth.setMt_state("未完成");
						this.getMyThingsService().save(mth);
					}

				}
			}else if("按周".equals(mt.getJiange())){
				Date da=new Date();
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(mt.getStartTime());
				Calendar ca1=Calendar.getInstance();
				ca1.setTime(dat);
				ca1.add(Calendar.DAY_OF_WEEK, 7);
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
				Date dat1=ca1.getTime();
				Date dat2=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(sf.format(da));
				if (dat1.equals(dat2) || dat2.after(dat1)) {
					MyThings mth=this.getMyThingsService().getTime(sf.format(dat1));
					if (mth==null) {
						mth=new MyThings();
						mth.setMt_type(mt.getMt_type());
						mth.setJiange(mt.getJiange());
						mth.setCycleTime(mt.getCycleTime());
						mth.setCycleStratTime(mt.getCycleStratTime());
						mth.setShichang(mt.getShichang());
						mth.setMt_thingsContext(mt.getMt_thingsContext());
						mth.setMt_importance(mt.getMt_importance());
						mth.setSendInfo(mt.getSendInfo());
						mth.setSendShouji(mt.getSendShouji());
						mth.setSendEmail(mt.getSendEmail());
						mth.setStartWarn(mt.getStartWarn());
						mth.setOutWarn(mt.getOutWarn());
						mth.setOverWarn(mt.getOverWarn());
						mth.setStartTime(sf.format(dat1));
						mth.setMt_state("未完成");
						this.getMyThingsService().save(mth);
					}
				}
			}
		}
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(MyThings.class).add(Restrictions.eq("mt_type", "周期日程"));
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getMyThingsService().listByPage(criteria, pagination));
		return SUCCESS;
	}

	@Action("listMyThing")
	public String listMyThing(){
		this.listMyThings();
		return SUCCESS;
	}

	@Action("editMyThings")
	public String editMyThings(){
		if (myThings!=null) {
		if (myThings.getMt_state().equals("未完成")) {
			this.addActionError("该事务正在进行中！");
			return ERROR;
		}
	}
		return SUCCESS;
	}
	
	@Action("editCycleMyThings")
	public String editCycleMyThings() throws ParseException{
		if (myThings!=null) {
			if ("未完成".equals(myThings.getMt_state())) {		
				Date date=new Date();
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(myThings.getStartTime());
				if (date.after(dat)) {
					this.addActionError("该日程正在进行中");
					return ERROR;
				}else{
					this.addActionError("该日程尚未进行");
					return ERROR;
				}
			}else{
				this.addActionError("该日程已经完成");
				return ERROR;
			}
		}
		return SUCCESS;
	}
	@Action(value = "saveMyThings", results = {
			@Result(name = "success", type = "redirect", location = "listMyThings"),
			@Result(name = "error", type = "chain", location = "editMyThings")
			})
	public String saveMyThings() throws ParseException{
			myThings.setReceivePersonName(AppContext.getAccountContext().currentUser().getResume().getName());
			myThings.setReceivePersonNameId(String.valueOf(AppContext.getAccountContext().currentUser().getResume().getId()));
			myThings.setMt_state("未完成");		
			this.myThingsService.saveMyThings(myThings);
			if ("按月".equals(myThings.getJiange())) {
				Date dt=new Date();
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM");
				String date=sf.format(dt);
				String day=myThings.getMonthTime();
				String time=myThings.getCycleStratTime();
				Integer day1=Integer.parseInt(day);
				if (day1>0 && day1<10) {
					myThings.setStartTime(date+"-"+"0"+day+" "+time);
				}else{
					myThings.setStartTime(date+"-"+day+" "+time);
				}
			}else if("按周".equals(myThings.getJiange())){
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd",Locale.CHINA);
				Calendar cd=Calendar.getInstance(Locale.CHINA);
				if("星期一".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
				}else if("星期二".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
				}else if("星期三".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
				}else if("星期四".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
				}else if("星期五".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
				}else if("星期六".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
				}else if("星期日".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
				}
				String time=myThings.getCycleStratTime();
				myThings.setStartTime(sf.format(cd.getTime())+" "+time);
			}else if("按天".equals(myThings.getJiange())){
				Date dt=new Date();
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
				String dat=sf.format(dt);
				String time=myThings.getCycleStratTime();
				myThings.setStartTime(dat+" "+time);
			}
			this.getMyThingsService().submit(myThings);
			
			//提醒设置
			Datetools  dt=new Datetools();
			Date startTime=myThings.getCs_beginTime();
			Date endTime=myThings.getCs_overTime();
			Date startTime1=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(myThings.getStartTime());
			if(myThings.getSendInfo()){
				if (myThings.getStartWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("开始之前");
					t1.setSendtype("系统");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOverWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("结束之前");
					t1.setSendtype("系统");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOutWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("超期之后");
					t1.setSendtype("系统");
					this.getTaskRemindService().save(t1);
				}
			}
			if (myThings.getSendEmail()) {
				if (myThings.getStartWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("开始之前");
					t1.setSendtype("邮件");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOverWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("结束之前");
					t1.setSendtype("邮件");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOutWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("超期之后");
					t1.setSendtype("邮件");
					this.getTaskRemindService().save(t1);
				}
			}
			if (myThings.getSendShouji()) {
				if (myThings.getStartWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("开始之前");
					t1.setSendtype("短信");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOverWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("结束之前");
					t1.setSendtype("短信");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOutWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("我的日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("超期之后");
					t1.setSendtype("短信");
					this.getTaskRemindService().save(t1);
				}
			}
		return SUCCESS;
	}
	@Action(value = "saveMyThings1", results = {
			@Result(name = "success", type = "redirect", location = "listCycleMyThings"),
			@Result(name = "error", type = "chain", location = "editCycleMyThings")
			})
	public String saveMyThings1() throws ParseException{
			myThings.setReceivePersonName(AppContext.getAccountContext().currentUser().getResume().getName());
			myThings.setReceivePersonNameId(String.valueOf(AppContext.getAccountContext().currentUser().getResume().getId()));
			myThings.setMt_state("未完成");		
			this.myThingsService.saveMyThings(myThings);
			if ("按月".equals(myThings.getJiange())) {
				Date dt=new Date();
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM");
				String date=sf.format(dt);
				String day=myThings.getMonthTime();
				String time=myThings.getCycleStratTime();
				Integer day1=Integer.parseInt(day);
				if (day1>0 && day1<10) {
					myThings.setStartTime(date+"-"+"0"+day+" "+time);
				}else{
					myThings.setStartTime(date+"-"+day+" "+time);
				}
			}else if("按周".equals(myThings.getJiange())){
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd",Locale.CHINA);
				Calendar cd=Calendar.getInstance(Locale.CHINA);
				if("星期一".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
				}else if("星期二".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
				}else if("星期三".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
				}else if("星期四".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
				}else if("星期五".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
				}else if("星期六".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
				}else if("星期日".equals(myThings.getCycleTime())){
					cd.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
				}
				String time=myThings.getCycleStratTime();
				myThings.setStartTime(sf.format(cd.getTime())+" "+time);
			}else if("按天".equals(myThings.getJiange())){
				Date dt=new Date();
				SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
				String dat=sf.format(dt);
				String time=myThings.getCycleStratTime();
				myThings.setStartTime(dat+" "+time);
			}
			this.getMyThingsService().submit(myThings);
			Datetools  dt=new Datetools();
			Date startTime=myThings.getCs_beginTime();
			Date endTime=myThings.getCs_overTime();
			Date startTime1=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(myThings.getStartTime());
			if(myThings.getSendInfo()){
				if (myThings.getStartWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("开始之前");
					t1.setSendtype("系统");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOverWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("结束之前");
					t1.setSendtype("系统");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOutWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("超期之后");
					t1.setSendtype("系统");
					this.getTaskRemindService().save(t1);
				}
			}
			if (myThings.getSendEmail()) {
				if (myThings.getStartWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("开始之前");
					t1.setSendtype("邮件");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOverWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("结束之前");
					t1.setSendtype("邮件");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOutWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("超期之后");
					t1.setSendtype("邮件");
					this.getTaskRemindService().save(t1);
				}
			}
			if (myThings.getSendShouji()) {
				if (myThings.getStartWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("开始之前");
					t1.setSendtype("短信");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOverWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("结束之前");
					t1.setSendtype("短信");
					this.getTaskRemindService().save(t1);
				}
				if (myThings.getOutWarn()) {
					TaskRemind t1=new TaskRemind();
					t1.setReState("1");
					t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
					t1.setReId(String.valueOf(myThings.getRecorder().getId()));
					t1.setRestyle("日程");
					if ("普通日程".equals(myThings.getMt_type())) {
						t1.setRestartTime(dt.getstrTime(startTime));
						t1.setReendTime(dt.getstrTime(endTime));
					}else{
						t1.setRestartTime(dt.getstrTime(startTime1));
					}
					t1.setResty("超期之后");
					t1.setSendtype("短信");
					this.getTaskRemindService().save(t1);
				}
			}
		return SUCCESS;
	}
	
	@Action(value = "saveFinish", results = {
			@Result(name = "success", type = "redirect", location = "listMyThings"),
			@Result(name = "error", type = "chain", location = "editMyThings")
			})
	public String saveFinish(){
		myThings.setMt_state("完成");
		this.myThingsService.submit(myThings);
		return SUCCESS;
	}
	@Action(value = "saveFinish1", results = {
			@Result(name = "success", type = "redirect", location = "listCycleMyThings"),
			@Result(name = "error", type = "chain", location = "editCycleMyThings")
			})
	public String saveFinish1(){
		myThings.setMt_state("完成");
		this.myThingsService.submit(myThings);
		return SUCCESS;
	}
	@Action(value = "removeThings", results = {
			@Result(name = "success", type = "redirect", location = "listMyThings"),
			@Result(name = "error", type = "chain", location = "editMyThings")
			})
	public String removeThings(){
		this.getMyThingsService().remove(myThings);
		return SUCCESS;
	}
	@Action(value = "removeThings1", results = {
			@Result(name = "success", type = "redirect", location = "listCycleMyThings"),
			@Result(name = "error", type = "chain", location = "editCycleMyThings")
			})
	public String removeThings1(){
		this.getMyThingsService().remove(myThings);
		return SUCCESS;
	}
	
	@Action(value = "saveCycleMyThings", results = {
			@Result(name = "success", type = "redirect", location = "listCycleMyThings"),
			@Result(name = "error", type = "chain", location = "editMyThings")
			})
	public String saveCycleMyThings(){
			myThings.setMt_state("未完成");
			this.myThingsService.saveMyThings(myThings);
		return SUCCESS;
	}
	
	@Action(value = "removeCycleMyThings", results = {
			@Result(name = "success", type = "redirect", location = "listCycleMyThings"),
			@Result(name = "error", type = "chain", location = "listCycleMyThings") })
	public String removeCycleMyThings(){
		if (ids==null) {
			this.addActionError("请选中一行进行操作！");
			return ERROR;
		}
		this.getMyThingsService().batchRemove(ids);
		this.setPrompt("删除成功！");
		return SUCCESS;	
	}
	@Action("editOthersThing")
	public String editOthersThing(){
		if (myThings!=null) {
			if (myThings.getMt_state()!=null) {
				if (myThings.getMt_state().equals("未完成")) {
				this.addActionError("该事务正在进行中！");
				return ERROR;
			}
		}
			
		}
		return SUCCESS;
	}
	@Action(value = "saveOthersThing1", results = {
			@Result(name = "success", type = "redirect", location = "listCycleMyThings"),
			@Result(name = "error", type = "chain", location = "editCycleOthersThing")
			})
	public String saveOthersThing1() throws ParseException{
		myThings.setMt_state("未完成");
		if(myThings.getMt_type()==null){
			this.addActionError("请选择日程类型！");
			return ERROR;
		}
//		if(myThings.getPersonName()==null || "".equals(myThings.getPersonName().trim())){
//			this.addActionError("请选择下属人员！");
//			return ERROR;
//		}
		if(myThings.getCs_beginTime()==null){
			myThings.setCs_beginTime(new Date());
		}
		if(myThings.getCs_overTime()==null){
			myThings.setCs_overTime(new Date());
		}
		myThings.setMt_state("未完成");
		String[] perName=myThings.getPersonNameId().split(",");
		for (String perNames : perName) {
		MyThings mt=new MyThings();
		mt.setMt_type("未完成");
		mt.setCs_beginTime(myThings.getCs_beginTime());
		mt.setCs_overTime(myThings.getCs_overTime());
		mt.setMt_thingsContext(myThings.getMt_thingsContext());
		mt.setReceivePersonNameId(perNames);
		Person person=this.getPersonService().getPersonById(Integer.parseInt(perNames));	
		if (person!=null) {
			mt.setReceivePersonName(person.getResume().getName());
		}
		mt.setMt_type(myThings.getMt_type());
		mt.setMt_importance(myThings.getMt_importance());
		mt.setSendEmail(myThings.getSendEmail());
		mt.setSendInfo(myThings.getSendInfo());
		mt.setSendShouji(myThings.getSendShouji());
		mt.setStartWarn(myThings.getStartWarn());
		mt.setOverWarn(myThings.getOverWarn());
		mt.setOutWarn(myThings.getOutWarn());
		mt.setJiange(myThings.getJiange());
		mt.setMonthTime(myThings.getMonthTime());
		mt.setCycleTime(myThings.getCycleTime());
		mt.setDateTime(myThings.getDateTime());
		mt.setCycleStratTime(myThings.getCycleStratTime());
		mt.setMt_state("未完成");
		mt.setShichang(myThings.getShichang());
		this.getMyThingsService().save(mt);
		if ("按月".equals(myThings.getJiange())) {
			Date dt=new Date();
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM");
			String date=sf.format(dt);
			String day=myThings.getMonthTime();
			String time=myThings.getCycleStratTime();
			Integer day1=Integer.parseInt(day);
			if (day1>0 && day1<10) {
				mt.setStartTime(date+"-"+"0"+day+" "+time);
			}else{
				mt.setStartTime(date+"-"+day+" "+time);
			}
		}else if("按周".equals(myThings.getJiange())){
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd",Locale.CHINA);
			Calendar cd=Calendar.getInstance(Locale.CHINA);
			if("星期一".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
			}else if("星期二".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
			}else if("星期三".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
			}else if("星期四".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
			}else if("星期五".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
			}else if("星期六".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
			}else if("星期日".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
			}
			String time=myThings.getCycleStratTime();
			mt.setStartTime(sf.format(cd.getTime())+" "+time);
		}else if("按天".equals(myThings.getJiange())){
			Date dt=new Date();
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
			String dat=sf.format(dt);
			String time=myThings.getCycleStratTime();
			mt.setStartTime(dat+" "+time);
		}
		this.getMyThingsService().submit(mt);
		Datetools  dt=new Datetools();
		Date startTime=myThings.getCs_beginTime();
		Date endTime=myThings.getCs_overTime();
		Date startTime1=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(mt.getStartTime());
		if(myThings.getSendInfo()){
			if (myThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
		}
		if (myThings.getSendEmail()) {
			if (myThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
		}
		if (myThings.getSendShouji()) {
			if (myThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
		}
	}
		return SUCCESS;
	}
	@Action("findOthersThing")
	public String findOthersThing(){
		return SUCCESS;
	}
	@Action(value = "queryOtherThing", results = {
			@Result(name = "success", type = "redirect", location = "listAllMyThings?myThings.receivePersonNameId=${myThings.getReceivePersonNameId()}"),
			@Result(name = "error", type = "chain", location = "queryOtherThing")
			})
	public String queryOtherThing(){
		if (myThings.getReceivePersonNameId()==null) {
			this.addActionError("请选择要查看的人");
			return ERROR;
		}
		this.getMyThingsService().findOtherThings(myThings.getReceivePersonNameId());
		return SUCCESS;
	}
	@Action("editCycleOthersThing")
	public String editCycleOthersThings() throws ParseException{
		if (myThings!=null) {
			if ("未完成".equals(myThings.getMt_state())) {		
				Date date=new Date();
				Date dat=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(myThings.getStartTime());
				if (date.after(dat)) {
					this.addActionError("该日程正在进行中");
					return ERROR;
				}else{
					this.addActionError("该日程尚未进行");
					return ERROR;
				}
			}else{
				this.addActionError("该日程已经完成");
				return ERROR;
			}
		}
		return SUCCESS;
	}
	@Action(value = "saveOthersThing", results = {
			@Result(name = "success", type = "redirect", location = "listMyThings"),
			@Result(name = "error", type = "chain", location = "editOthersThing")
			})
	public String saveOthersThing() throws ParseException{
		if(myThings.getMt_type()==null){
			this.addActionError("请选择日程类型！");
			return ERROR;
		}
//		if(myThings.getPersonName()==null || "".equals(myThings.getPersonName().trim())){
//			this.addActionError("请选择下属人员！");
//			return ERROR;
//		}
		if(myThings.getCs_beginTime()==null){
			myThings.setCs_beginTime(new Date());
		}
		if(myThings.getCs_overTime()==null){
			myThings.setCs_overTime(new Date());
		}
		myThings.setMt_state("未完成");
		String[] perName=myThings.getPersonNameId().split(",");
		for (String perNames : perName) {
		MyThings mt=new MyThings();
		mt.setMt_type("未完成");
		mt.setCs_beginTime(myThings.getCs_beginTime());
		mt.setCs_overTime(myThings.getCs_overTime());
		mt.setMt_thingsContext(myThings.getMt_thingsContext());
		mt.setReceivePersonNameId(perNames);
		Person person=this.getPersonService().getPersonById(Integer.parseInt(perNames));	
		if (person!=null) {
			mt.setReceivePersonName(person.getResume().getName());
		}
		mt.setMt_type(myThings.getMt_type());
		mt.setMt_importance(myThings.getMt_importance());
		mt.setSendEmail(myThings.getSendEmail());
		mt.setSendInfo(myThings.getSendInfo());
		mt.setSendShouji(myThings.getSendShouji());
		mt.setStartWarn(myThings.getStartWarn());
		mt.setOverWarn(myThings.getOverWarn());
		mt.setOutWarn(myThings.getOutWarn());
		mt.setJiange(myThings.getJiange());
		mt.setMonthTime(myThings.getMonthTime());
		mt.setCycleTime(myThings.getCycleTime());
		mt.setDateTime(myThings.getDateTime());
		mt.setCycleStratTime(myThings.getCycleStratTime());
		mt.setMt_state("未完成");
		mt.setShichang(myThings.getShichang());
		this.getMyThingsService().save(mt);
		if ("按月".equals(myThings.getJiange())) {
			Date dt=new Date();
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM");
			String date=sf.format(dt);
			String day=myThings.getMonthTime();
			String time=myThings.getCycleStratTime();
			Integer day1=Integer.parseInt(day);
			if (day1>0 && day1<10) {
				mt.setStartTime(date+"-"+"0"+day+" "+time);
			}else{
				mt.setStartTime(date+"-"+day+" "+time);
			}
		}else if("按周".equals(myThings.getJiange())){
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd",Locale.CHINA);
			Calendar cd=Calendar.getInstance(Locale.CHINA);
			if("星期一".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
			}else if("星期二".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
			}else if("星期三".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
			}else if("星期四".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
			}else if("星期五".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
			}else if("星期六".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
			}else if("星期日".equals(myThings.getCycleTime())){
				cd.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
			}
			String time=myThings.getCycleStratTime();
			mt.setStartTime(sf.format(cd.getTime())+" "+time);
		}else if("按天".equals(myThings.getJiange())){
			Date dt=new Date();
			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
			String dat=sf.format(dt);
			String time=myThings.getCycleStratTime();
			mt.setStartTime(dat+" "+time);
		}
		this.getMyThingsService().submit(mt);
		Datetools  dt=new Datetools();
		Date startTime=myThings.getCs_beginTime();
		Date endTime=myThings.getCs_overTime();
		Date startTime1=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(mt.getStartTime());
		if(myThings.getSendInfo()){
			if (myThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("系统");
				this.getTaskRemindService().save(t1);
			}
		}
		if (myThings.getSendEmail()) {
			if (myThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("邮件");
				this.getTaskRemindService().save(t1);
			}
		}
		if (myThings.getSendShouji()) {
			if (myThings.getStartWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("开始之前");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOverWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
			
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("结束之前");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
			if (myThings.getOutWarn()) {
				TaskRemind t1=new TaskRemind();
				t1.setReState("1");
				t1.setReContent("你所担任"+myThings.getMt_thingsContext()+"即将开始");
				t1.setRestyle("周期日程");
				if ("普通日程".equals(myThings.getMt_type())) {
					t1.setRestartTime(dt.getstrTime(startTime));
					t1.setReendTime(dt.getstrTime(endTime));
				}else{
					t1.setRestartTime(dt.getstrTime(startTime1));
				}
				t1.setResty("超期之后");
				t1.setSendtype("短信");
				this.getTaskRemindService().save(t1);
			}
		}
	}
		return SUCCESS;
	}
}
